package com.fg.cloud.common.shiro;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

import com.fg.cloud.common.construction.Resource;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

/**
 * 自定义Authentication对象，使得Subject除了携带用户的登录名外还可以携带更多信息
 * @author around
 * @date 2017-7-21
 */
public class ShiroUser implements Serializable {

    private static final long serialVersionUID = -1373760761780840081L;
    
    /** 用户ID */
    private final Long id;
    
    private Long facId;
    
    /** 用户登陆名 */
    private String userName;
    
    /** 用户显示名称 */
    private String trueName;
    
    private String type;
    
    /** 用户具有的角色 */
    public Set<String> roleList = Sets.newHashSet();
    
    public Set<String> urlSet = Sets.newHashSet();
    
    /** 用户具有菜单+按钮 */
    private List<Resource> resourceList = Lists.newArrayList();
    
    public String firstRoleName;

    public ShiroUser(Long id, String userName, String trueName, Set<String> roleList) {
        this.id = id;
        this.userName = userName;
        this.trueName = trueName;
        this.roleList = roleList;
    }
    
    public ShiroUser(Long id, String userName, String trueName, String type) {
        this.id = id;
        this.userName = userName;
        this.trueName = trueName;
        this.type = type;
    }
    
    public String getFirstRoleName(){
    	return firstRoleName;
    }

    public void setFirstRoleName(String firstRoleName){
    	this.firstRoleName = firstRoleName;
    }
    
    public String getTrueName() {
		return trueName;
	}
    
	public Set<String> getRoleList() {
		return roleList;
	}

	public Set<String> getUrlSet() {
		return urlSet;
	}
	
	public List<Resource> getResourceList() {
		return resourceList;
	}

	public void setResourceList(List<Resource> resourceList) {
		this.resourceList = resourceList;
	}
	
	

	public Long getFacId() {
		return facId;
	}

	public void setFacId(Long facId) {
		this.facId = facId;
	}
	
	

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Long getId() {
		return id;
	}

	public void setTrueName(String trueName) {
		this.trueName = trueName;
	}

	/**
     * 本函数输出将作为默认的<shiro:principal/>输出.
     */
    @Override
    public String toString() {
        return userName;
    }
}